package com.goparry.taskman.restclient;

public final class RESTUtilities {
	public enum SERVER { GAE, DEV, LOCAL }
	private static int SERVERNUM;
	static private String serverUri;

	protected RESTUtilities(){
	}
	
	//
	// Methods to set the Server, options are Google App Engine, GoParry dev server or run locally.
	//
	static public void setServer(SERVER serverID) {
		switch (serverID) {
		case GAE:
			serverUri = "http://taskman-goparry.appspot.com/taskman/";
			SERVERNUM=0;
			return;
		case DEV:
			serverUri = "http://192.168.1.2:8888/taskman/";
			SERVERNUM=1;
			return;
		case LOCAL:
			serverUri = "local";
			SERVERNUM=2;
			return;
		default:
			serverUri = "http://taskman-goparry.appspot.com/taskman/robjects/";
			SERVERNUM=0;
			return;
		}
	}
	static public void setServerAsString(String server) {
		SERVER serverID = SERVER.LOCAL;
		if (server.equalsIgnoreCase(SERVER.GAE.toString())) serverID = SERVER.GAE;
		if (server.equalsIgnoreCase(SERVER.DEV.toString())) serverID = SERVER.DEV;
		setServer(serverID);
	}
	static public int getServerNumber() {
		return SERVERNUM;
	}
	//
	// Set of methods to generate the URI to the REST Server
	//
	static public String getVaultsURI() {
		String uri = serverUri + "vaults";		
		return uri;
	}
	static public String getDocumentsByNameURI(String name) {
		String uri = serverUri + "documents/search?name=" + name;
		return uri;
	}
	static public String getDocumentsByTagIdURI(String name) {
		String uri = serverUri + "documents/search?tagid=" + name;
		return uri;
	}
	static public String getDocumentsByAssetCodeURI(String name) {
		String uri = serverUri + "documents/search?assetid=" + name;
		return uri;
	}
	static public String getDocumentsByIDsURI(String IDs) {
		String uri = serverUri + "documents/search?docids=" + IDs;
		return uri;
	}
	static public String getContaineesURI(String parentID) {
		String uri = serverUri + "containees?folderid=" + parentID;
		return uri;
	}
	static public String getTasksURI() {
		String uri = serverUri + "tasks";		
		return uri;
	}

	public static String getDocumentsByGeoURI(String id) {
		String uri = serverUri + "documents/search?geo=" + id;
		return uri;
	}
}
